<?php


namespace api\channel\coupon;

use app\model\BaseSupplier;
use app\model\CouponOrder;

class BaseHandler
{
    /**
     * 请求地址
     * @var string $bestUrl
     */
    protected $bestUrl;

    /**
     * 密匙apiKey
     * @var string $apiKey
     */
    protected $apiKey;

    /**
     * 状态码
     * @var array $codeMsg
     */
    protected $codeMsg = [];

    /**
     * 头部
     * @var array $header
     */
    protected $header = [];

    /**
     * 回调地址
     * @var array $notifyUrl
     */
    protected $notifyUrl;

    /**
     * 渠道商信息
     * @var object $supplier
     */
    protected $supplier;

    /**
     * Notes:数字签名计算方式
     * User: ymzhang
     * Date: 2022/06/28
     * Time: 15:45
     * @return string
     */
    protected function generateSign()
    {
        $numargs = func_num_args();
        $arg_list = func_get_args();
        $sign = '';
        for ($i = 0; $i < $numargs; $i++) {
            $sign.= $arg_list[$i];
        }
        return strtolower(md5($sign));
    }

    /**
     * Notes:获取密匙apiKey
     * User: ymzhang
     * Date: 2022/06/28
     * Time: 15:45
     * @return string
     */
    public function getSupplier()
    {
        return $this->supplier;
    }

    /**
     * Notes:获取渠道商对象
     * User: ymzhang
     * Date: 2022/06/28
     * Time: 15:45
     * @return string
     */
    public function getKey()
    {
        return $this->apiKey;
    }

    /**
     * Notes:获取接口地址
     * User: ymzhang
     * Date: 2022/06/28
     * Time: 15:45
     * @return string
     */
    public function getBaseUrl()
    {
        return $this->bestUrl;
    }

    /**
     * Notes:获取提示消息
     * User: ymzhang
     * Date: 2022/06/29
     * Time: 13:50
     * @param string $code
     * @return string
     */
    public function getMsg(string $code)
    {
        return $this->codeMsg[$code]??'';
    }

    /**
     * Notes:获取回调地址
     * User: ymzhang
     * Date: 2022/06/30
     * Time: 10:30
     * @return string
     */
    public function getNotifyUrl()
    {
        return $this->notifyUrl;
    }

}